{extend name="../../base/view/common/base" /}
{block name="style"}
<style>
.log-timeline{ position: relative; padding-left: 48px; background-color:#fff;}
.log-timeline:after {content: ""; position: absolute; top: 0; left: 24px; width: 1px; height: 100%; background: #e3e9ed;}
.log-timeline dl{padding-bottom: 8px; position: relative;}
.log-timeline dt{font-size: 16px; line-height: 2.4; color: #323232; font-weight:600}
.log-timeline dd{font-size: 14px; line-height: 1.6; padding:5px 0}
.log-timeline .date-second-point{width: 10px; height: 10px; display: block; border-radius: 50%; border: 3px solid #FBBC05; background: #fff; position: absolute; z-index: 99; left:-32px; top:9px}
.log-timeline .log-thumb{width: 24px; height: 24px; border-radius: 50%; margin-right:4px;}
.log-timeline .open-a{margin:0 4px;}
.log-item i{font-weight:800; color:#323232}
.log-content strong{margin:0 4px; color:#323232}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-page">
	<h3 class="pb-3">
	法院详情	
	</h3>
	<table class="layui-table layui-table-form">
	  <tr>
		<td class="layui-td-gray">法院名称</td>
		<td colspan="3">{$detail.name}【{$detail.level_text|default=''}】</td>
		<td class="layui-td-gray">录入时间</td>
		<td>{$detail.create_time|date='Y-m-d H:i:s'|default=''}</td>
	  </tr>
	  <tr>
		<td class="layui-td-gray">地址</td>
		<td colspan="3">{$detail.full_address|default=''}</td>
		<td class="layui-td-gray">最后更新</td>
		<td>{$detail.update_time|date='Y-m-d H:i:s'|default=''}</td>
	  </tr>
	  <tr>
		<td class="layui-td-gray">关联案件</td>
		<td colspan="5">{$detail.case_count|default='0'} 件</td>
	  </tr>
	  <tr>
		<td class="layui-td-gray">备注信息</td>
		<td colspan="5">{$detail.description|default=''}</td>
	  </tr>
	</table>
	<div class="body-table layui-tab layui-tab-brief bg-white" lay-filter="courtTab" id="courtTab">
		<ul class="layui-tab-title border">
			<!-- <li>基本信息</li> -->
			<li class="layui-this" data-load="true">联系电话</li>
		</ul>
		<div class="layui-tab-content" style="padding:0;">
			<div class="layui-tab-item">
				<!-- 原有基本信息内容 -->
			</div>
			<div class="layui-card">
				<div class="layui-card-body">
					<table id="dataTable" lay-filter="dataTable"></table>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add">
            <i class="layui-icon">&#xe654;</i>新增电话
        </button>
    </div>
</script>

<script type="text/html" id="toolbar-action">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
const court_id = '{$detail.id}';
const moduleInit = ['tool'];
	function gouguInit() {
		var form = layui.form, tool=layui.tool, element = layui.element, table = layui.table;

		//渲染表格
		table.render({
        elem: '#dataTable',
        url: '/lawcase/api/get_court_phones?court_id=' + court_id,
        method: 'get',
        toolbar: '#toolbar',
        defaultToolbar: ['filter', 'exports', 'print'],

        cols: [[
            {field: 'id', title: 'ID', width: 80, sort: true},
            {field: 'phone', title: '法院电话', minWidth: 150},
            {field: 'description', title: '电话描述', width: 120},
            {field: 'create_time', title: '创建时间', width: 180, templet: function(d){
                return d.create_time ? layui.util.toDateString(d.create_time * 1000) : '';
            }},
            {field: 'update_time', title: '修改时间', width: 180, templet: function(d){
                return d.update_time ? layui.util.toDateString(d.update_time * 1000) : '';
            }},
            {title: '操作', toolbar: '#toolbar-action', width: 200, fixed: 'right'}
        ]],
        page: false
    });

		// 表格工具栏事件
		table.on('toolbar(dataTable)', function(obj){
        if (obj.event === 'add') {
            tool.side("/lawcase/court/addphone?court_id=" + court_id, '添加联系电话');
        }});

		// 监听工具栏事件
		table.on('tool(dataTable)', function(obj){
			var data = obj.data;
			if(obj.event === 'edit'){
				tool.side("/lawcase/court/addphone?id=" + data.id, '编辑联系电话');
			} else if(obj.event === 'del'){
				layer.confirm('确定要删除吗？', function(index){
					tool.delete("/lawcase/court/deletephone", {id: data.id}, function(res){
						if(res.code == 0) {
							table.reload('dataTable');
						}
					});
					layer.close(index);
				});
			}
		});
	}
</script>
{/block}
<!-- /脚本 -->